home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / faq / kjvcbibl.lha / cbible / rexx / dir.thnkr < prev    next >
Text File  |  1993-03-18  |  3KB  |  106 lines

  1. /*                                                          */
  2. /* Directory listing program for Thinker                    */
  3. /*                                                          */
  4. /*     When used as a macro from Thinker, this program      */
  5. /*     adds a branch for the named directory (or current)   */
  6. /*     and builds a tree of branches naming all files and   */
  7. /*     directories.  The directory branches have labels     */
  8. /*     with the full path name of the directory and the     */
  9. /*     data in the statement is the short name.  For files  */
  10. /*     a two line statement is added with the first line    */
  11. /*     being the short file name and the second line is a   */
  12. /*     full link to that file.  Example                     */
  13. /*                                                          */
  14. /*                                                          */
  15. /*     (sys:devs)sys:devs                                   */
  16. /*        (sys:devs/keymaps)keymaps                         */
  17. /*           usa2~                                          */
  18. /*                  <sys:devs/keymaps/usa2,>                */
  19. /*           usa0~                                          */
  20. /*                  <sys:devs/keymaps/usa0,>                */
  21. /*        (sys:devs/Printers)Printers                       */
  22. /*           HP_PaintJet~                                   */
  23. /*                  <sys:devs/Printers/HP_PaintJet,>        */
  24. /*        clipboard.device                                  */
  25. /*                <sys:devs/clipboard.device,>              */
  26. /*        narrator.device                                   */
  27. /*                <sys:devs/narrator.devic,>                */
  28. /*                                                          */
  29.  
  30.   parse arg dirname .
  31. options results
  32. trace off
  33.  
  34. call addlib "rexxsupport.library",0,-30,0
  35.  
  36. home=pragma('directory','')
  37. if dirname="" then dirname=home
  38.  
  39. 'get title'  /* get file name displayed in active window */
  40.              /* this works when using either REXX or Thinker */ 
  41.              /* as the port when the "dir" command is issued */
  42. if rc ~= 0 then return 1  /* must have active file */
  43. 'get origin' result
  44. if rc ~= 0 then return 2  /* cant set file*/
  45.  
  46. 'get label first' dirname
  47. if rc ~= 0 then do
  48.     'get origin'
  49.     'add after same' '('dirname')'dirname
  50. end
  51. l=length(dirname)
  52. flag=0
  53. if substr(dirname,l,1) = ':' then flag=1
  54.  
  55. call dodir dirname,dirname,flag
  56. return
  57.  
  58. dodir: procedure
  59.    parse arg fullname,dirname,flag
  60.  
  61. 'get label first' fullname
  62.  
  63. dirstr=showdir(fullname,'dir')
  64. nwords=words(dirstr)
  65.  
  66. do i=1 to nwords by 1
  67.     name=word(dirstr,i)
  68.     if flag= 1 then
  69.         newfullname=fullname ||  name
  70.     else
  71.         newfullname=fullname || '/' || name
  72.     'get label first' newfullname
  73.     if rc ~= 0 then do
  74.         'get label first' fullname
  75.         'add after down' '('newfullname')'name
  76.     end
  77.     call dodir newfullname,name,0 
  78. end
  79.  
  80. 'get label first' fullname
  81. level='down'
  82.  
  83. 'get down'
  84.  
  85. do while rc = 0 
  86. 'get succeeding' 
  87. level='same' 
  88. end 
  89.  
  90. dirstr=showdir(fullname,'file')
  91. nwords=words(dirstr)
  92.  
  93. do i=1 to nwords by 1
  94.     name=word(dirstr,i)
  95.     
  96.     if flag= 1 then
  97.         newfullname=fullname || name
  98.     else
  99.         newfullname=fullname || '/' || name
  100.  
  101.     'add after' level name '0A'X '     ' '<'newfullname',>'
  102.     level='same'
  103. end
  104.  
  105. return 0
  106.